import { Component, OnInit } from '@angular/core';
import { ActionSheetController,AlertController } from '@ionic/angular';


@Component({
  selector: 'app-action-sheet',
  templateUrl: './action-sheet.page.html',
  styleUrls: ['./action-sheet.page.scss'],
})
export class ActionSheetPage implements OnInit {

  constructor(
    private actionSheetController: ActionSheetController,
    private alertController: AlertController,
  ) { }

  ngOnInit() {
  }


  async presentActionSheet(){
    const actionSheet = await this.actionSheetController.create({
      header: 'Test',
      buttons: [{
        text: 'Delete',
        role: 'destructive',
        icon: 'trash',
        handler: ()=>{
          console.log('选中了删除');
          const alert = this.alertController.create({
            header: 'Alert',
            message: '已删除',
            buttons: ['OK']
          }).then(alert =>alert .present());
        }
      },{
        text: 'Share',
        icon: 'share',
        handler: () => {
          console.log('选中了Share');
        }
      },{
        text: 'Cancel',
        role: 'cancel',
        icon: 'close',
        handler: () => {
          console.log('退出');
        }
      }]
    });

    await actionSheet.present();
  }

}
